package com.yoomiito.app.ui.anyview.shareview

import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.widget.ImageView
import android.widget.LinearLayout
import com.yoomiito.app.R
import com.yoomiito.app.utils.AllUtils
import com.yoomiito.app.utils.DensityUtil
import com.yoomiito.app.utils.ImageUtils
import com.yoomiito.app.utils.L

class MeiTuanShareAdView(context: Context,val qrCode:String):BaseShareView(context){
    private var mPicLoadSuccess = false
    init {
        parentView(R.layout.view_meituan_share)
    }

    override fun initView() {
        val bg = view.findViewById<LinearLayout>(R.id.bgView)
        view.findViewById<ImageView>(R.id.qrCodeIv).setImageBitmap(getQRCode(qrCode))
        L.i("生成VIew")
        getBitmapFromUrl("https://mimitao-cdn.aijiamai.com/app/share@3x.png?${AllUtils.getVersionInfo().versionName}"){
            L.i("获取回调")
            bg.background = BitmapDrawable(null,it)
            mPicLoadSuccess = true
            makePic()
        }
    }

    override fun makePic() {
        L.i("生成图片")
        ImageUtils.layoutView(view,DensityUtil.dp2px(375f),DensityUtil.dp2px(545f))
        if (mPicLoadSuccess){
            L.i("开始回调View：$onPicMakeListener")
            onPicMakeListener(view,ImageUtils.viewSaveToImage(view))
        }
    }

}